# encoding: utf-8
class ApplicationController < ActionController::Base
  protect_from_forgery
  
  # Method that checks if the user is logged in
  #
  # * *Returns* :
  #   - true if session[:user] exists and the user is logged in
  #   - false if user is not logged in
  #
  def login_required
    if session[:user]
      return true
    else
      flash[:warning] = 'Kirjaudu sisään jatkaaksesi'
      redirect_to :controller => 'users', :action => 'login'
      return false
    end
  end
  
end
